﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;

namespace lchealthy
{
    public partial class frmreports : Form
    {
        private string cid;
        private DataSet ds;
        public frmreports(string id)
        {
            cid = id;
            InitializeComponent();
        }

        private void frmreports_Load(object sender, EventArgs e)
        {
            string sql = "select [CID],[MDate],[MWeight],[MBMI],[MFatAll],[MFatUp],[MMetaAll],[MMeatUp],[MThews],[MThewType],[MWater],[MAge],[MFatIn],[MBone],[MXW],[MUBelly],[MDBelly],[Mwaistline],[MHip],[MRleg],[MRARM],[MRSlet],[MReaction],[mid] from measureInfo where cid="+cid;// +cid;
            ds = DbHelperOleDb.Query(sql);
            GraphPane myPane = zedone.GraphPane;
            GraphPane mypane1 = zedGraphControl1.GraphPane;
            //myPane.LineType=
            myPane.Title.Text = "测量数据变化情况";
            myPane.XAxis.Title.Text = "时间";
            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.CrossAuto = true;            
            myPane.XAxis.Scale.Format = "MM月dd日";
            myPane.YAxis.Title.Text = "值";
            mypane1.Title.Text = "测量数据变化情况";
            mypane1.XAxis.Title.Text = "时间";
            mypane1.XAxis.Type = AxisType.Text;
            mypane1.XAxis.CrossAuto = true;
            mypane1.XAxis.Scale.Format = "MM月dd日";
            mypane1.YAxis.Title.Text = "值";
            Double[] sw = new Double[ds.Tables[0].Rows.Count];
            Double[] sb = new Double[ds.Tables[0].Rows.Count];
            double[] sf = new double[ds.Tables[0].Rows.Count];
            double[] water = new double[ds.Tables[0].Rows.Count];
            double[] age = new double[ds.Tables[0].Rows.Count];
            double[] MXW = new double[ds.Tables[0].Rows.Count];
            double[] Mwaistline = new double[ds.Tables[0].Rows.Count];
            double[] MHip = new double[ds.Tables[0].Rows.Count];
            double[] MUBelly = new double[ds.Tables[0].Rows.Count];
            double[] MDBelly = new double[ds.Tables[0].Rows.Count];
            string[] strdate = new String[ds.Tables[0].Rows.Count];
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                strdate[i] = Convert.ToDateTime(ds.Tables[0].Rows[i]["mdate"]).ToString("M月d日");
                //体重                                      
                sw[i]=Convert.ToDouble(ds.Tables[0].Rows[i]["mweight"]);                
                //BMI
               sb[i]=Convert.ToDouble(ds.Tables[0].Rows[i]["mbmi"]);
                //脂肪
               sf[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MFatAll"]);
                //MWater
               water[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MWater"]); 
                //age
               age[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MAge"]);
               MXW[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MXW"]);
               Mwaistline[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["Mwaistline"]);
               MHip[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MHip"]);
               MUBelly[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MUBelly"]);
               MDBelly[i] = Convert.ToDouble(ds.Tables[0].Rows[i]["MDBelly"]); 

            }
            LineItem li = myPane.AddCurve("体重",null, sw, Color.Blue, ZedGraph.SymbolType.Star);
            LineItem libmi = myPane.AddCurve("BMI",null,sb, Color.Red);
            LineItem li1 = myPane.AddCurve("脂肪", null, sf, Color.Green);
            LineItem li2 = myPane.AddCurve("水分", null, water, Color.Lime);
            LineItem li3 = myPane.AddCurve("生理年龄", null, age, Color.Black);
            //LineItem libmi = myPane.AddCurve("BMI", null, sb, Color.Red);
            LineItem l1 = mypane1.AddCurve("胸围", null, MXW, Color.Blue, ZedGraph.SymbolType.Star);
            LineItem l2 = mypane1.AddCurve("腰围", null, Mwaistline, Color.Red, ZedGraph.SymbolType.Triangle);
            LineItem l3 = mypane1.AddCurve("臀围", null, MHip, Color.Green, ZedGraph.SymbolType.Circle);
            LineItem l4 = mypane1.AddCurve("上腹", null, MUBelly, Color.Lime, ZedGraph.SymbolType.Diamond);
            LineItem l5 = mypane1.AddCurve("下腹", null, MDBelly, Color.Black, ZedGraph.SymbolType.Star);
            myPane.XAxis.Scale.TextLabels = strdate;
            zedone.MasterPane.AxisChange();
            zedone.Refresh();
            mypane1.XAxis.Scale.TextLabels = strdate;
            zedGraphControl1.MasterPane.AxisChange();
            zedGraphControl1.Refresh();
        }

        private void zedone_MouseMove(object sender, MouseEventArgs e)
        {

        }

        private void zedGraphControl1_Load(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
